#ifndef SOCKETHTTPADAPTER_H
#define SOCKETHTTPADAPTER_H

#include <As/Http/AbstractHttpAdapter.h>

#include <QtNetwork/QTcpServer>
#include <QMap>

namespace As {

class SocketHttpAdapter : public AbstractHttpAdapter {
        Q_OBJECT;
public:
        SocketHttpAdapter(const QString & host, int port, bool startListen = true,
                      QObject *parent = 0);
        ~SocketHttpAdapter();

public slots:
        void listen();
        void stopListen();
        void response(As::HttpResponse resp);

private slots:
        void newConnection();
        void readClient();
        void discardClient();

private:
        QString m_host;
        int m_port;
        QTcpServer m_server;
        QMap<QTcpSocket *, QString> m_socketMap;
};

}

#endif // SOCKETHTTPADAPTER_H
